﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Nebular.ExpenseManagement.Model
{
    static class StringExtensions
    {
        public static string SubstringAfter(this string source, string value)
        {
            if (string.IsNullOrEmpty(source) || string.IsNullOrEmpty(value))
                return source;
            int index = source.IndexOf(value, StringComparison.Ordinal);
            return (index >= 0)
                ? source.Substring(index + value.Length)
                : source;
        }

        public static string SubstringBefore(this string source, string value)
        {
            if (string.IsNullOrEmpty(source) || string.IsNullOrEmpty(value))
                return source;
            int index = source.IndexOf(value, StringComparison.Ordinal);
            return (index >= 0)
                ? source.Substring(0, index)
                : source;
        }
    }
}
